/* QtLua -- Lua bindings for Qt
   Copyright (C) 2011, Jarek Pelczar

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library; if not, write to the
   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301 USA

*/

#ifndef WRAP_QPOINT_H
#define WRAP_QPOINT_H

#include <QObject>
#include <QPoint>
#include "qluascriptable.h"
#include "qluascriptengine.h"
#include "qluascriptvalue.h"
#include "qluascriptclass.h"
#include "qluaglobal.h"

class QPoint_Prototype : public QObject, public QLuaScriptable
{
    Q_OBJECT
    Q_INTERFACES(QLuaScriptable)
    Q_PROPERTY(int x READ getX WRITE setX)
    Q_PROPERTY(int y READ getY WRITE setY)
public:
    QPoint_Prototype(QObject * parent = 0);

public slots:
    bool isNull() const;

    int getX() const;
    int getY() const;
    void setX(int x);
    void setY(int y);

    int manhattanLength() const;

    QPointF toPointF() const;

private:
    QPoint * ptr() const;
};

class QPointF_Prototype : public QObject, public QLuaScriptable
{
    Q_OBJECT
    Q_INTERFACES(QLuaScriptable)
    Q_PROPERTY(qreal x READ getX WRITE setX)
    Q_PROPERTY(qreal y READ getY WRITE setY)
public:
    QPointF_Prototype(QObject * parent = 0);

public slots:
    bool isNull() const;

    qreal getX() const;
    qreal getY() const;
    void setX(qreal x);
    void setY(qreal y);

    qreal manhattanLength() const;

    QPoint toPoint() const;

private:
    QPointF * ptr() const;
};

class QPoint_wrapper : public QObject, public QLuaScriptClass
{
    Q_OBJECT
    Q_INTERFACES(QLuaScriptClass)
public:
    QPoint_wrapper(QLuaScriptEngine * engine);

    virtual QueryFlags queryProperty(const QLuaScriptValue& object,
                                     const QByteArray& name);
    virtual QLuaScriptValue property(const QLuaScriptValue& object,
                                          const QByteArray& name);
    virtual QLuaScriptValue prototype() const;
    virtual QString name() const;

private:
    static QLuaScriptValue QPoint_toScriptValue(QLuaScriptEngine * engine, const QPoint * t);
    static void QPoint_fromScriptValue(const QLuaScriptValue& value, QPoint * t);
    static QLuaScriptValue new_point(QLuaScriptContext *, QLuaScriptEngine *);

private:
    QLuaScriptValue m_proto;
};

class QPointF_wrapper : public QObject, public QLuaScriptClass
{
    Q_OBJECT
    Q_INTERFACES(QLuaScriptClass)
public:
    QPointF_wrapper(QLuaScriptEngine * engine);

    virtual QueryFlags queryProperty(const QLuaScriptValue& object,
                                     const QByteArray& name);
    virtual QLuaScriptValue property(const QLuaScriptValue& object,
                                          const QByteArray& name);
    virtual QLuaScriptValue prototype() const;
    virtual QString name() const;

private:
    static QLuaScriptValue QPointF_toScriptValue(QLuaScriptEngine * engine, const QPointF * t);
    static void QPointF_fromScriptValue(const QLuaScriptValue& value, QPointF * t);
    static QLuaScriptValue new_pointF(QLuaScriptContext *, QLuaScriptEngine *);

private:
    QLuaScriptValue m_proto;
};

#endif // WRAP_QPOINT_H
